Hair rendering method and apparatus, electronic device and storage medium

ABSTRACT

A hair rendering method includes acquiring a target video containing hair information, and selecting a target image frame from image frames of the target video, acquiring a texture image of the target image frame, wherein the texture image is an image in a texture format which records motion states and state change information of one or more pixel points in the target image frame. 
     The method further includes acquiring a first target motion state and target state change information of a first target particle region from the texture image; determining a second target motion state of the first target particle region in a next image frame according to the first target motion state and the target state change information, and rendering the hair region by updating a motion state in the texture image according to the second target motion state.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a continuation application of InternationalApplication No. PCT/CN2020/129859, filed Nov. 18, 2020, which claimspriority to and benefits of Chinese Patent Application No.202010230272.6, filed on Mar. 27, 2020, the entire content of which isincorporated herein by reference.

FIELD

The present disclosure relates to the field of image processingtechnology, and more particularly to a hair rendering method andapparatus, an electronic device and a storage medium.

BACKGROUND

With the development of live streaming and other technologies, real-timerendering technology is more and more widely used in mobile terminals,for example, to dye or soften the user's hair in images and videosduring a live streaming process.

SUMMARY

According to one aspect of embodiments of the present disclosure, a hairrendering method is provided, which includes acquiring a target videocontaining hair information, and selecting a target image frame fromimage frames of the target video, and acquiring a texture image of thetarget image frame, wherein the texture image is an image in a textureformat which records motion states and state change information of oneor more pixel points in the target image frame, and a hair region in thetexture image is divided into at least one particle region by a gridline.

The method further includes acquiring a first target motion state andtarget state change information of a first target particle region fromthe texture image, wherein the first target particle region is anyregion of the at least one particle region, determining a second targetmotion state of the first target particle region in a next image frameaccording to the first target motion state and the target state changeinformation, wherein the next image frame is an image frame in thetarget video next to the target image frame, and rendering the hairregion by updating a motion state in the texture image according to thesecond target motion state.

According to another aspect of embodiments of the present disclosure, anelectronic device is provided, which includes: a processor; and amemory, configured to store an instruction executable by the processor,wherein the processor is configured to acquire a target video containinghair information, and select a target image frame from image frames ofthe target video, and acquire a texture image of the target image frame,wherein the texture image is an image in a texture format which recordsmotion states and state change information of one or more pixel pointsin the target image frame, and a hair region in the texture image isdivided into at least one particle region by a grid line. The processoris further configured to acquire a first target motion state and targetstate change information of a first target particle region from thetexture image, wherein the first target particle region is any region ofthe at least one particle region, determine a second target motion stateof the first target particle region in a next image frame according tothe first target motion state and the target state change information,wherein the next image frame is an image frame in the target video nextto the target image frame, and render the hair region by updating amotion state in the texture image according to the second target motionstate.

According to another aspect of embodiments of the present disclosure, astorage medium is provided, which has stored therein instructions that,when executed by a processor of an electronic device, cause theelectronic device to acquire a target video containing hair information,and select a target image frame from image frames of the target video,and acquire a texture image of the target image frame, wherein thetexture image is an image in a texture format which records motionstates and state change information of one or more pixel points in thetarget image frame, and a hair region in the texture image is dividedinto at least one particle region by a grid line. The electronic deviceis further configured to acquire a first target motion state and targetstate change information of a first target particle region from thetexture image, wherein the first target particle region is any region ofthe at least one particle region, determine a second target motion stateof the first target particle region in a next image frame according tothe first target motion state and the target state change information,wherein the next image frame is an image frame in the target video nextto the target image frame, and render the hair region by updating amotion state in the texture image according to the second target motionstate. According to another aspect of the present disclosure, a computerprogram product is provided. The program product includes a computerprogram, and the computer program is stored in a readable storagemedium. The computer program, when read from the readable storage mediumand executed by at least one processor of a device, causes the device toacquire a target video containing hair information, and select a targetimage frame from image frames of the target video, and acquire a textureimage of the target image frame, wherein the texture image is an imagein a texture format which records motion states and state changeinformation of one or more pixel points in the target image frame, and ahair region in the texture image is divided into at least one particleregion by a grid line. The at least one processor of the device furthercauses the device to acquire a first target motion state and targetstate change information of a first target particle region from thetexture image, wherein the first target particle region is any region ofthe at least one particle region, determine a second target motion stateof the first target particle region in a next image frame according tothe first target motion state and the target state change information,wherein the next image frame is an image frame in the target video nextto the target image frame, and render the hair region by updating amotion state in the texture image according to the second target motionstate. It should be appreciated that, the general descriptionhereinbefore and the detail description hereinafter are explanatory andillustrative, and shall not be construed to limit the presentdisclosure.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, which are incorporated in and constitute apart of this specification, illustrate embodiments consistent with thepresent disclosure and, together with the description, serve to explainthe principles of the present disclosure, and shall not be construed toimproperly limit the present disclosure.

FIG. 1 is a diagram showing an application environment of a hairrendering method according to an exemplary embodiment.

FIG. 2 is a flow chart showing a hair rendering method according to anexemplary embodiment.

FIG. 3 is a schematic diagram showing particle bunches according to anexemplary embodiment.

FIG. 4 is a schematic diagram showing a displaying effect of hairrendering according to an exemplary embodiment.

FIG. 5 is a flow chart showing a hair rendering method according toanother exemplary embodiment.

FIG. 6 is a block diagram showing a hair rendering apparatus accordingto an exemplary embodiment.

DETAILED DESCRIPTION

In order to make those ordinarily skilled in the art better understandthe technical solutions of the present disclosure, the technicalsolutions in embodiments of the present disclosure will be describedclearly and completely below with reference to the accompanyingdrawings.

It should be noted that the terms “first”, “second” and the like in thespecification, claims and the accompanying drawings of the presentdisclosure are used to distinguish similar objects, and not necessarilyused to describe a specific order or sequence. It should be understoodthat the terms so used may be interchangeable where appropriate, suchthat embodiments of the present disclosure described herein may beimplemented in a sequence other than those illustrated or describedherein. The embodiments described in the following illustrative examplesare not intended to represent all embodiments consistent with thepresent disclosure. On the contrary, they are merely examples of devicesand methods consistent with some aspects of the present disclosure asrecited in the appended claims.

At present, pixels in a hair region are rendered by such as colorreplacement or a blurring treatment through a CPU (central processingunit) on a PC (personal computer) terminal or a server terminal.

However, the current rendering methods have a large computation burden,and the processing of the CPU on hair particle information is oftencomplicated, it is impossible to achieve real-time rendering on themobile terminal. At present, the demand for live broadcast throughmobile terminals is increasing, so it is necessary to provide a methodthat can render hair in real time on mobile terminals.

The preset disclosure provides a hair rendering method and apparatus, anelectronic device and a storage medium, to solve at least the problemexisting in the related art that the hair cannot be rendered in realtime on the mobile terminal. The technical solutions of the presentdisclosure are as follows.

According to embodiments of the present disclosure, a hair renderingmethod is provided, which includes: acquiring a target video containinghair information, and selecting a target image frame from image framesof the target video; acquiring a texture image of the target imageframe, wherein the texture image is an image in a texture format whichrecords motion states and state change information of one or more pixelpoints in the target image frame, and a hair region in the texture imageis divided into at least one particle region by a grid line; acquiring afirst target motion state and target state change information of a firsttarget particle region from the texture image, wherein the first targetparticle region is any region of the at least one particle region;determining a second target motion state of the first target particleregion in a next image frame according to the first target motion stateand the target state change information, wherein the next image frame isan image frame in the target video next to the target image frame; andrendering the hair region by updating a motion state in the textureimage according to the second target motion state.

In some embodiments, the updating the motion state in the texture imageaccording to the second target motion state includes: updating a motionstate of the first target particle region according to the second targetmotion state, and retaining a motion state of a remaining particleregion. The remaining particle region is a particle region of the atleast one particle region other than the first target particle region.

In some embodiments, the first target motion state includes a firstscreen coordinate, and the target state change information includes afirst speed. The determining the second target motion state of the firsttarget particle region in the next image frame according to the firsttarget motion state and the target state change information includes:determining a time difference between the target image frame and thenext image frame; determining a second screen coordinate of the firsttarget particle region in the next image frame according to the firstscreen coordinate, the first speed and the time difference; anddetermining the second target motion state based on the second screencoordinate.

In some embodiments, the updating the motion state in the texture imageaccording to the second target motion state includes: in response to thesecond screen coordinate being outside the hair region, redeterminingthe hair region of the texture image and determining a second targetparticle region from particle regions corresponding to the redeterminedhair region; acquiring a reference target motion state and a referencetarget state change information of the second target particle regionfrom the texture image; obtaining a third target motion state bydetermining a motion state of the second target particle region in thenext image frame according to the reference target motion state and thereference target state change information; and updating the motion statein the texture image according to the third target motion state.

In some embodiments, the first target motion state includes a secondspeed, and the target state change information includes a hairdirectional angle. The determining the second target motion state of thefirst target particle region in the next image frame according to thefirst target motion state and the target state change informationincludes: acquiring a preset rate; and obtaining the second targetmotion state by determining a third speed of the first target particleregion in the next image according to the second speed, the hairdirectional angle and the preset rate.

In some embodiments, before the acquiring the texture image of thetarget image frame, the hair rendering method further includes:determining candidate state change information of each pixel point inthe target image frame according to pixel state information in thetarget video which varies over time; acquiring a hair directional mapand a hair region mask map corresponding to the target image frame,wherein the hair directional map includes a hair directional angle ofthe pixel point, and the hair region mask map includes mask informationof the hair region in the target image frame; determining a candidatemotion state of the pixel point according to the hair directional anglein the hair directional map and the mask information in the hair regionmask map; and storing the candidate state change information and thecandidate motion state to a vertex position of the at least one particleregion, wherein the vertex position of the at least one particle regioncorresponds to the pixel point.

In some embodiments, after storing the candidate state changeinformation and the candidate motion state to the vertex position of theat least one particle region, the hair rendering method furtherincludes: storing the texture image to a first frame buffer; and afterupdating the motion state in the texture image according to the secondtarget motion state, the hair rendering method further includes: storingthe texture image in the first frame buffer to a second frame buffer;and storing an updated texture image to the first frame buffer.

In some embodiments, after acquiring the texture image of the targetimage frame, the hair rendering method further includes: determining thehair region in the texture image; meshing the hair region according tothe preset number of particle bunches to correspondingly obtain at leastone particle bunch; and meshing each of the at least one particle bunchaccording to the preset number of particles to correspondingly obtain atleast one particle region.

In some embodiments, before acquiring the first target motion state andthe target state change information of the first target particle regionfrom the texture image, the hair rendering method further includes:determining a particle region at a preset position of the at least oneparticle bunch as the first target particle region.

The texture image of the target image frame is acquired according to thetarget video containing the hair information, and the texture image canbe processed by a GPU (graphics processing unit); the hair region in thetexture image is divided into at least one particle region, and theparticle region is processed by the GPU, which greatly simplifies thegraphics processing of the GPU and improves the graphics processingefficiency of the GPU, so that the computation on the mobile terminal isrealized; in addition, the first target motion state and the targetstate change information of the target particle region are acquired fromthe texture image, based on which the second target motion state of thefirst target particle region in the next image frame is determined, andthe motion state in the texture image is updated according to the secondtarget motion state to realize the rendering of the hair region. Theabove technical solution according to the present disclosure is able torender the hair region in real time on the mobile terminal, and at thesame time is able to modify the motion state of a particular particleregion, so that a special rendering effect that particles flow along adirection of the hair filament may be realized.

The hair rendering method provided in the present disclosure may beapplied to a device 100 as shown in FIG. 1 . The device 100 may be amobile terminal, such as a mobile phone, a computer, a digital broadcastterminal, a messaging device, a gaming console, a tablet, a medicaldevice, exercise equipment, a personal digital assistant, and the like.

Referring to FIG. 1 , the device 100 may include one or more of thefollowing components: a processing component 101, a memory 102, a powercomponent 103, a multimedia component 104, an audio component 105, aninput/output (I/O) interface 106, a sensor component 107, and acommunication component 108. These components are described in detail asfollows.

The processing component 101 typically controls overall operations ofthe device 100, such as operations associated with display, telephonecalls, data communications, camera operations, and recording operations.The processing component 101 may include one or more processors 109 toexecute instructions to perform all or part of the steps in theabove-described method. Moreover, the processing component 101 mayinclude one or more modules which facilitate interaction between theprocessing component 101 and other components. For instance, theprocessing component 101 may include a multimedia module to facilitateinteraction between the multimedia component 104 and the processingcomponent 101.

The memory 102 is configured to store various types of data to supportthe operation of the device 100. Examples of such data includeinstructions for any applications or methods operated on the device 100,contact data, phonebook data, messages, pictures, videos, etc. Thememory 102 may be implemented using any type of volatile or non-volatilememory devices, or a combination thereof, such as a static random accessmemory (SRAM), an electrically erasable programmable read-only memory(EEPROM), an erasable programmable read-only memory (EPROM), aprogrammable read-only memory (PROM), a read-only memory (ROM), amagnetic memory, a flash memory, a magnetic disk or an optical disk.

The power component 103 provides power to various components of thedevice 100. The power component 103 may include a power managementsystem, one or more power sources, and any other components associatedwith the generation, management, and distribution of power in the device100.

The multimedia component 104 includes a screen providing an outputinterface between the device 100 and a user. In some embodiments, thescreen may include a liquid crystal display (LCD) and a touch panel(TP). If the screen includes a touch panel, the screen may beimplemented as a touch screen to receive input signals from the user.The touch panel includes one or more touch sensors to sense touches,swipes, and gestures on the touch panel. The touch sensors may not onlysense a boundary of a touch or swipe action, but also sense a period oftime and a pressure associated with the touch or swipe action. In someembodiments, the multimedia component 104 includes a front camera and/ora rear camera. The front camera and/or the rear camera may receiveexternal multimedia data while the device 100 is in an operation mode,such as a photographing mode or a video mode. Each of the front cameraand the rear camera may be a fixed optical lens system or have focus andoptical zoom capability.

The audio component 105 is configured to output and/or input audiosignals. For example, the audio component 105 includes a microphone(MIC) configured to receive an external audio signal when the device 100is in an operation mode, such as a call mode, a recording mode, and avoice recognition mode. The received audio signal may be further storedin the memory 102 or transmitted via the communication component 108. Insome embodiments, the audio component 105 further includes a speaker tooutput audio signals.

The I/O interface 106 provides an interface between the processingcomponent 101 and a peripheral interface module, such as a keyboard, aclick wheel, buttons, and the like. The buttons may include, but are notlimited to, a home button, a volume button, a starting button, and alocking button.

The sensor component 107 includes one or more sensors to provide statusassessments of various aspects of the device 100. For instance, thesensor component 107 may detect an open/closed status of the device 100,relative positioning of components, e.g., the display and the keyboard,of the device 100, a change in position of the device 100 or a componentof the device 100, a presence or absence of user contact with the device100, an orientation or an acceleration/deceleration of the device 100,and a change in temperature of the device 100. The sensor component 107may include a proximity sensor configured to detect a presence of nearbyobjects without any physical contact. The sensor component 107 may alsoinclude a light sensor, such as a CMOS or CCD image sensor, for use inimaging applications. In some embodiments, the sensor component 107 mayalso include an accelerometer sensor, a gyroscope sensor, a magneticsensor, a pressure sensor, or a temperature sensor.

The communication component 108 is configured to facilitatecommunication, wired or wireless, between the device 100 and otherdevices. The device 100 may access a wireless network based on acommunication standard, such as WiFi, an operator network (such as 2G,3G, 4G or 5G) or a combination thereof. In an exemplary embodiment, thecommunication component 108 receives a broadcast signal or broadcastassociated information from an external broadcast management system viaa broadcast channel. In an exemplary embodiment, the communicationcomponent 108 further includes a near field communication (NFC) moduleto facilitate short-range communications. For example, the NFC modulemay be implemented based on a radio frequency identification (RFID)technology, an infrared data association (IrDA) technology, anultra-wideband (UWB) technology, a Bluetooth (BT) technology, and othertechnologies.

In an exemplary embodiment, the device 100 may be implemented with oneor more application specific integrated circuits (ASICs), digital signalprocessors (DSPs), digital signal processing devices (DSPDs),programmable logic devices (PLDs), field programmable gate arrays(FPGAs), controllers, micro-controllers, microprocessors, or otherelectronic components, for performing the above-described methods.

FIG. 2 is a flow chart of a hair rendering method according to anexemplary embodiment of the present disclosure, which may be applied tothe device 100 as shown in FIG. 1 (specifically to the processor 109 asshown in FIG. 1 , and more specifically to a GPU (graphics processingunit) of the device 100). As shown in FIG. 2 , the hair rendering methodincludes the following steps S201/S202/S203/S204/S205, which aredescribed in detail below.

In step S201, a target video containing hair information is acquired,and a target image frame is selected from image frames of the targetvideo.

The target video may be a video obtained by shooting a head of a humanbody (or an animal body) through a shooting device. The shooting devicemay be the sensor component 107 of the device 100, or may be a camerathat has a network connection relationship with the device 100.

The hair information contained in the target video may refer to aposition where the hair region is located, a size of the hair region, areal-time position of the hair region, a hair color, a length anddirection of a hair filament, and the like information.

The camera may shoot the target video containing the hair informationwithin a set period of time, and send the shot target video to thedevice 100 (or directly to the processor of the device 100) for hairrendering by the processor. Furthermore, the camera may shoot targetvideos in advance and send the shot target videos to the device 100together; or the camera may send the target video to the processor inreal time during the shooting process.

Further, each time sequence of the target video corresponds to an imageframe, and the device 100 may perform a hair rendering treatment on oneor some image frames of the target video in one hair rendering program,and the one or some image frames may be understood as the target imageframe. The target image frame may be an image frame randomly selectedfrom the target video, or may be several consecutive image framesselected in a time sequence.

In step S202, a texture image of the target image frame is acquired. Thetexture image is an image in a texture format which records motionstates and state change information of one or more pixel points in thetarget image frame, and a hair region in the texture image is dividedinto at least one particle region by a grid line.

The texture format is a pixel format that can be recognized by the GPU.The texture image in embodiments of the present disclosure is the imagein the texture format. Further, the texture image may also be directlyreferred to as “texture” for short, which may be a half float (halffloating-point) or float (floating-point) type texture map.

In this step, the texture image of the target image frame is acquired,which is processed by the GPU of the device. The hair region in thetexture image may be determined according to the color of each pixelpoint in the target image frame. For example, a black region with anarea larger than a set value is determined as the hair region, and thencorresponding information is filled in a corresponding grid of thetexture image to characterize the hair region in the texture image. Ofcourse, the process of determining the hair region may also beimplemented by machine learning. For example, a plurality of videoscontaining the hair information are input into a pre-built neuralnetwork model, and corresponding information of the hair region in eachimage frame of each video is also input into the neural network model,the neural network model uses the input information to performself-learning and completes the training process, after which, thetarget video shot by the camera is input to the neural network model,and the neural network model can automatically output the hair region ineach image frame of the target video.

Further, the hair region in the texture image is divided into at leastone particle region (in some cases, other regions outside the hairregion may also be meshed to obtain corresponding particle regions), andthe at least one particle region may be obtained through dividing thetexture image by the device 100, an external device of the device 100 orother components (such as the sensor component) other than the processorin the device 100, after the texture image is acquired. Furthermore, thehair region corresponding to the texture image may be divided accordingto the set number of grid lines, and the particle regions may bedetermined according to obtained grids; or the texture image may bedivided according to the distribution of hair filaments, for example,hair bunches (a distance between the hair filaments is small enough) aredetermined as the particle regions. In addition, the number of theparticle regions in the texture image may be determined according to anactual situation. In a case where the hair region needs to be renderedmore accurately, the number of the particle regions may be larger. In acase where the hair region needs to be rendered more roughly, the numberof the particle regions may be smaller.

Further, the target image frame may be an image frame displayed on adisplay screen of the device 100, that is, the texture image recordsparticle information of the image frame currently displayed on thedisplay screen, and the particle information includes the motion statesand the state change information of one or more pixel point (for eachpixel point, there may be a corresponding particle region) in the targetimage frame. The motion state is a state of a particle in acorresponding image frame, which may be position information, speedinformation (including a rate and a direction), a hair directionalangle, a size, etc.; and the state change information may refer toinformation describing the state change of the particle, which cancharacterize the motion state of the particle in a next image frame, andmay be a speed, a hair directional angle, a rotation direction, a lifecycle, etc. It should be noted that some particle information may beeither the motion state or the state change information. For example,the speed can not only characterize rate and direction information of acertain image frame (in this case, it may be used as the motion state),but also characterize a moving state of the image frame (in this case,it may be used as the state change information, and can determine amoving distance of the particle in combination with time information, soas to determine a position coordinate of the particle). Specifically,where a position of a particle in a next image frame needs to becomputed, a speed may be used to evaluate the position of the particleat a next moment, in this case, the position information may be used asthe movement state, while the speed may be used as the state changeinformation; where a speed of a particle in a next image frame needs tobe computed, a rate may be used to evaluate the speed of the particle ata next moment, in this case, the speed may be used as the movementstate, while the rate may be used as the state change information. Inthese cases, the speed is used as either the motion state or the statechange information.

In an exemplary embodiment, due to the limited storage channels in thetexture image, in a case where one texture image is not enough to storethe motion state or the state change information, two texture images maybe used. For example, for texture images each having only 4 channels,two texture images may be used to store the position information, thespeed information (including the rate and the direction), and otherinformation in dimensions like the hair directional angle, the rotationdirection, the life cycle, and the size.

In step S203, a first target motion state and target state changeinformation of a first target particle region are acquired from thetexture image. The first target particle region is any region of the atleast one particle region.

Each particle in the texture image may have its own number, and theparticle information of each particle is stored in a correspondingparticle region of the texture image. The target particle region may berandomly selected from the particle regions of the texture image, or maybe selected according to a specific rule (for example, selecting aparticle region at a specific location). Further, from the particleinformation recorded in the target particle region, corresponding targetmotion state and state change information may be obtained, therebyobtaining the first target motion state and the target state changeinformation.

The specific process of the step S203 may be implemented by: acquiringat least one of a screen coordinate, a speed, a directional angle, arotation posture, a current life state, a life cycle, and a size of thetarget particle from the texture image, and obtaining the first targetmotion state and the target state change information according to theacquired information (the corresponding target state change informationmay be determined according to the motion state to be updatedcurrently).

In an exemplary embodiment, after the step of acquiring the textureimage of the target image frame, the method further includes:determining the hair region in the texture image; meshing the hairregion according to the preset number of particle bunches tocorrespondingly obtain at least one particle bunch; and meshing each ofthe at least one particle bunch according to the preset number ofparticles to correspondingly obtain at least one particle region.

The number of the particle bunches is used to characterize the number ofparticle bunches contained in the hair region, and may be determinedaccording to a screen resolution, a rendering precision, etc.; and thenumber of the particles is used to characterize the number of particleregions contained in the particle bunch, and may also be determinedaccording to the screen resolution, the rendering precision, etc.Further, after the number of the particle bunches and the number of theparticles are known, the hair region or the particle bunch may bedivided by the grid lines at same or different intervals. Further, thehair region or the particle bunch may be divided horizontally,vertically, or both horizontally and vertically (in this case, theinterval in a horizontal direction may be the same as or different fromthat in a vertical direction), or may be divided by lines at a certainangle (for example,)30° relative to a horizontal line of the screen.

A schematic diagram of the texture image may be as shown in FIG. 3 , inwhich the left figure shows a girl's head profile, which includes a hairprofile (indicated by thick solid lines) and a face profile (indicatedby thin solid lines), and these two profiles constitute a hair region301 and a face region 302, respectively. Further, the hair region 301 isdivided into a plurality of particle bunches (each show as 305). Asshown in FIG. 3 , a grid region 303 surrounded by thick dashed lines maybe understood as a particle bunch. Further, each of these particlebunches is divided into a plurality of small regions, and these smallregions may be referred as the first target particle regions 304 (mayalso be referred as hair particles or particles, the specific divisionmay be seen in the enlarged diagram at the right side of FIG. 3 ).

It should be noted that FIG. 3 shows a case where the entire textureimage is meshed, however, in an actual application scenario, it ispossible to only mesh the hair region (or the hair region and the faceregion). Furthermore, a video contains a plurality of frames, andbecause the head position may change, the hair region in each frame mayalso change. Therefore, after a texture image is acquired, it ispossible to redetermine the hair region and mesh the hair region.

In an exemplary embodiment, before the step of acquiring the firsttarget motion state and the target state change information of the firsttarget particle region of the at least one particle region from thetexture image, the method further includes: determining a particleregion at a preset position of the at least one particle bunch as thefirst target particle region. The preset position may refer to aparticle region at a center c, a head position (the position where thefirst number is located), or a tail position (the position where thelast number is located) in a certain particle bunch.

Further, in embodiments of the present disclosure, the target particleregion (as indicated by 304 in FIG. 3 ) is selected from a plurality ofparticle regions 305 of the particle bunch. The target particle region304 may be randomly selected, or a particle at a center position or anedge position may be selected as the target particle region. In someexemplary embodiments, the target particle region may also be referredto as a head particle (this particle drives other particles to moveduring the rendering process). On the other hand, the selection methodof the target particle in different particle bunches of the same textureimage may be the same or different. For example, in the latter case, theselection of the target particle may be specifically implemented asfollows: in a certain particle bunch, a particle region at an edgeposition may be selected as the target particle region, while in anotherparticle bunch, a particle region at center position may be selected asthe target particle region. In addition, the number of target particleregions corresponding to a particle bunch may be one, two or more.Furthermore, the target particle region may be those selected frompartial or all particle bunches of the hair region, or from a certainparticle bunch. By dividing the hair region in the texture image, themotion state of particular particle regions may be updated, so thatthese particle regions show a gradual change state in the finaldisplayed video, thereby achieving a special rendering effect thatparticles flow in a direction of the hair filament.

In step 5204, a second target motion state of the first target particleregion in a next image frame is determined according to the first targetmotion state and the target state change information. The next imageframe is an image frame in the target video next to the target imageframe.

The next image frame is an image frame of the target image frame at anext moment. The “next moment” may be determined according to a framesampling rate. For example, assuming that 60 image frames are generatedwithin 1 min (one image frame per second (s)), if the frame samplingrate is 5 s/frame, the next image frame is separated from the targetimage frame by 4 image frames, while if the frame sampling rate is 1s/frame, the next image frame is separated from the target image frameby 0 image frames (that is, the next image frame is adjacent to thetarget image frame). Therefore, the selection of the image frame may beadjusted according to actual situations. For example, where a highrendering precision is required, the frame sampling rate may take a lowvalue (more image frames need to be processed in this case), and where alow rendering precision is required, the frame sampling rate may take ahigh value.

The first target motion state characterizes the motion state of thefirst target particle region in the target image frame, and the targetstate change information characterizes the influence of the first targetparticle region on the state change in the target image frame.Therefore, based on the first target motion state and the target statechange information, the motion state of the first target particle regionin the next image frame may be obtained, that is, a second target motionstate may be obtained. For example, the texture image contains thefollowing particle information: a position coordinate of the firsttarget particle region is (2,2), its speed direction is 36.87° relativeto a positive direction of a screen horizontal line (may be recorded asan x-axis), and the speed value is 5 mm/s, among which the positioncoordinate belongs to the first target motion state, while the speeddirection and the speed value belong to the target state changeinformation. According to the above information, it can be determinedthat, from the target image frame to the next image frame (taking thetime interval between the target image frame and the next image frame is1 s as example), the first target particle region moves 3 mm in thepositive direction of the x-axis, and moves 4 mm in a y-axis. Therefore,it can be determined that the position coordinate of the first targetparticle region in the next image frame are (5,6), so the second targetmotion state is obtained.

In step S205, the hair region is rendered by updating a motion state inthe texture image according to the second target motion state. Updatingthe motion state in the texture image may be understood as directlyreplacing the first target motion state in the texture image with thesecond target motion state.

The display screen of the device 100 displays the target image frameaccording to the texture image at the beginning. After the texture imageis updated, the corresponding next image frame may be displayed on thedisplay screen. At this time, the motion state of the first targetparticle region in the screen will change from the first target motionstate to the second target motion state, thereby achieving a renderingeffect that particular particles in the hair region is flowing.

Further, the completion of the switch between the target image frame andthe next image frame may be regarded as the completion of the renderingof the hair region for one time. Next, new rendering may be continued.

In the above-described hair rendering method, the texture image of thetarget image frame is acquired according to the target video containingthe hair information, and the texture image can be processed by the GPU;the hair region in the texture image is divided into at least oneparticle region, and the particle region is processed by the GPU, whichgreatly simplifies the graphics processing of the GPU and improves thegraphics processing efficiency of the GPU, so that the computation onthe mobile terminal is realized; in addition, the first target motionstate and the target state change information of the target particleregion are acquired from the texture image, based on which the secondtarget motion state of the first target particle region in the nextimage frame is determined, and the motion state in the texture image isupdated according to the second target motion state to realize therendering of the hair region. The above technical solution according tothe present disclosure is able to render the hair region in real time onthe mobile terminal, and at the same time is able to modify the motionstate of a particular particle region, so that a special renderingeffect that particles flow along the direction of the hair filament maybe realized.

In an exemplary embodiment, the step of updating the motion state in thetexture image according to the second target motion state includes:updating a motion state of the first target particle region according tothe second target motion state, and retaining a motion state of aremaining particle region (also referred to as a tail particle region ora tail particle). The remaining particle region is a particle region ofthe at least one particle region other than the first target particleregion.

As shown in the enlarged diagram of the part marked as 303 in FIG. 3 ,all or part of the particles in the particle bunch other than the firsttarget particle region 304 may be regarded as the remaining particleregion, as indicated by 305 in FIG. 3 . In an exemplary embodiment, theprocess for determining the first target particle region 304 and theremaining particle region 305 may be as follows: assuming that thetexture image storing the particle information has a resolution of W*H,and there are m particles and n particles distributed in W and Hdirections, respectively, so the total number of particles is m*n, wherem≤W, and n≤H; assuming that each particle bunch is composed of Kparticles, n/K grids are divided in the H direction, and each gridstores information of a bunch of particles. Each grid is divided into Ksubintervals k(i), where i ranges from 0 to K−1, in which k( 0 ) is thetarget particle (i.e., the head particle) of the particle bunch, whilek(1) to k(K−1) are remaining particles (i.e., tail particles) of theparticle bunch. Among others, the values of W/H/m/n/K/k may bedetermined according to actual situations. In embodiments of the presentdisclosure, the motion state of the remaining particle region 305 in thenext image frame directly adopts the motion state of the remainingparticle region 305 in the target image frame, while the motion state ofthe first target particle region 304 is updated in real time. Based onthis, the display state in the display screen is that: the state of thefirst target particle region 304 changes, while the state of theremaining particle region 305 does not change. In this way, display ofthe next image frame after display of the target image frame willgenerate a “tailing” effect, which has high applicability in games andother scenarios that require a “tailing” effect. Referring to FIG. 4 , aschematic display diagram of the hair region of the target image framemay be as shown by a left FIG. 400 of FIG. 4 (the grid lines may not bedisplayed), from which the state of the hair filament can be seenclearly; after rendering, the hair region with tailing effect may be asshown by a right FIG. 402 of FIG. 4 , in which the gray region 401 maybe the first target particle region, and the hair filament in the firsttarget particle region is blurred due to motion during frame switching,while the state of particles in other regions remains unchanged, and thehair filament can still be seen clearly, so that the special renderingeffect that the particle bunch flows along the direction of the hairfilament and the “tailing” effect are realized. In an exemplaryembodiment, the motion state of the remaining particle region in thenext image frame may not adopt the corresponding reference remainingmotion state in the target image frame, but is obtained by: acquiring acandidate remaining motion state in accordance with the determinationmethod of the second target motion state, determining a differencebetween the candidate remaining motion state and the reference remainingmotion state, multiplying the difference by a certain percentage (forexample, 30%) and summing the obtained product with the referenceremaining motion state to obtain the motion state of the remainingparticle region in the next image frame. In this way, the state of theremaining particles also will change in the rendering process, but themagnitude of the change is not as large as the target particle, so thatthe “tailing” effect can be generated, and the flow of the hair is morenatural.

Further, in an exemplary embodiment, the target particle region or theremaining particle region may be subjected to other operations likecolor rendering (for example, replacing black particles with goldenparticles) according to the needs of the scenario.

In an exemplary embodiment, the first target motion state includes afirst screen coordinate, and the target state change informationincludes a first speed. The determining the second target motion stateof the first target particle region in the next image frame according tothe first target motion state and the target state change informationincludes: determining a time difference between the target image frameand the next image frame; determining a second screen coordinate of thefirst target particle region in the next image frame according to thefirst screen coordinate, the first speed and the time difference; anddetermining the second target motion state based on the second screencoordinate.

The time difference between the target image frame and the next imageframe may be determined according to the frame sampling rate asdescribed in the foregoing embodiments. Further, it may be determinedaccording to an overall frame rate of a video effect. For example, theframe rate of the special effect set by a certain app product is 30 fps,then the time difference (delta t) between adjacent image frames isabout 1000/30=33 ms, if the target image frame and the next image frameare adjacent, then the time difference between the target image frameand the next image frame is 33 ms.

The screen coordinate may be understood as a position coordinate of thevertex of the first target particle region in the display screen of thedevice 100.

Further, the screen coordinate of the first target particle region maybe updated by updating the vertex position of the first target particleregion, but not updating other positions.

In embodiments of the present disclosure, the second screen coordinateof the first target particle region in the next image frame isdetermined according to the first screen coordinate, the first speed andthe time difference, and the second target motion state is determinedbased on the second screen coordinate. In some embodiments, the secondscreen coordinate is regarded as the second target motion state. Theprocess for determining the motion state is simple, which caneffectively improve the rendering efficiency of the hair region andrealize real-time rendering on the mobile terminal.

Further, in an exemplary embodiment, the step of updating the motionstate in the texture image according to the second target motion stateincludes: in response to the second screen coordinate being outside thehair region, redetermining the hair region of the texture image anddetermining a second target particle region from particle regionscorresponding to the redetermined hair region; acquiring a referencetarget motion state and a reference target state change information ofthe second target particle region from the texture image; obtaining athird target motion state by determining a motion state of the secondtarget particle region in the next image frame according to thereference target motion state and the reference target state changeinformation; and updating the motion state in the texture imageaccording to the third target motion state.

The second screen coordinate may be compared with the coordinate of eachparticle region in the hair region, and in response to the second screencoordinate being not matched with the coordinate of any particle regionin the hair region, it is determined that the second screen coordinateis outside the hair region.

It should be noted that, for the step of “obtaining a third targetmotion state by determining the motion state of the second targetparticle region in the next image frame according to the referencetarget motion state and the reference target state change information”,reference may be made to the process of “determining the second targetmotion state of the first target particle region in the next image frameaccording to the first target motion state and the target state changeinformation” as described in the above embodiments, and for the step of“updating the motion state in the texture image according to the thirdtarget motion state”, reference may be made to the process of “updatingthe motion state in the texture image according to the second targetmotion state” as described in the above embodiments, both of which willnot be elaborated here again. In embodiments of the present disclosure,in a case where it is determined that the target particle is outside thehair region corresponding to the target image frame, the motion state(i.e., the third target motion state) of the target particle isredetermined, and the texture image is updated according to the thirdtarget motion state, which ensures the continuity of the hair regiondisplayed on the display screen, so that sudden deformation of the hairregion will not occur, thereby ensuring good hair display effect.

In an exemplary embodiment, in a case where a screen coordinatecorresponding to the third target motion state is still outside the hairregion, a new motion state may be determined according to the thirdtarget motion state and third target state change information, and soon, until the determined screen coordinate is in the hair region. Ofcourse, in some cases where the determined screen coordinate (includingthe aforementioned second screen coordinate) is outside the hair region,but its distance from the edge of the hair region is less than a presetthreshold (the threshold may be determined according to actualsituations, which will not be limited herein), the texture image may bedirectly updated according to the second target motion state withoutredetermining the motion state, which can effectively reduce the amountof computation while ensuring good hair display effect.

In an exemplary embodiment, the first target motion state includes asecond speed, and the target state change information includes a hairdirectional angle. The step of determining the second target motionstate of the first target particle region in the next image frameaccording to the first target motion state and the target state changeinformation includes: acquiring a preset rate; and obtaining the secondtarget motion state by determining a third speed of the first targetparticle region in the next image according to the second speed, thehair directional angle and the preset rate.

It should be noted that both the first speed and the second speed arespeed information obtained from a certain channel in the same textureimage, and their magnitudes may be the same. When updating the screencoordinate, if the screen coordinate is to be updated according to thespeed, the speed is used as the state change information; when updatingthe speed, the speed is used as the motion state.

The rate may also be called as velocity scalar, which is used to controlthe flow rate of particles. The rate may be preset by a user or may bedetermined by a certain algorithm (for example, the velocity scalargradually decreases with time).

The hair directional angle may refer to an angle of the speed of thefirst target particle region relative to the positive direction of thescreen horizontal line, the x-axis, and the hair directional angle maybe understood as a motion direction of the first target particle regionand may be represented by D(cost, sint), where t represents an angle ofthe target particle relative to the positive direction of the x-axis,cost represents a component of a moving distance of the first targetparticle region in the x-axis, and sint represents a component of themoving distance of the first target particle region in the y-axis.

Further, the third speed may be computed by the following formula:

the third speed=the second speed+the hair directional angle * the rate,

where the second speed includes a speed value and a directional angle.Therefore, the summing of “the second speed” and “the hair directionalangle * the rate” not only includes the summing of the speed values, butalso include the fusion of the directional angles.

In another exemplary embodiment, the second speed may not be consideredin the determination of the third speed, and the product of the hairdirectional angle and the rate may be directly used as the third speed.The specific computation formula may be as follows:

the third speed v(u,v)=D(cost, sint) * V,

where D(cost, sint) represents the hair directional angle, and V is auser-defined rate. In this way, the speed of the first target particleregion may be controlled by the device 100, so that the flow rate of thehair filament may be controlled according to the needs of the user, soas to achieve a more personalized hair display effect.

In the above embodiment, the speed information of the next image frameis determined according to the directional angle and the rate, and thedetermination process is simple, which can effectively improve thecomputation efficiency and realize the real-time rendering on the mobileterminal.

In an exemplary embodiment, before the step of acquiring the textureimage of the target image frame, the hair rendering method furtherincludes: determining candidate state change information of each pixelpoint in the target image frame according to pixel state information inthe target video which varies over time; acquiring a hair directionalmap and a hair region mask map corresponding to the target image frame,wherein the hair directional map includes a hair directional angle ofthe pixel point, and the hair region mask map includes mask informationof the hair region in the target image frame; determining a candidatemotion state of the pixel point according to the hair directional anglein the hair directional map and the mask information in the hair regionmask map; and storing the candidate state change information and thecandidate motion state to a vertex position of the at least one particleregion, wherein the vertex position of the at least one particle regioncorresponds to the pixel point.

The pixel state information may refer to state information related tosuch as color and position of each pixel in the video and therelationship of state change between pixel points over time (forexample, in a certain frame, a certain pixel point P1 is pure black, butin the next frame, the pixel point P2 adjacent to the pixel point P1changes to pure black, while the pixel point P1 changes to othercolors). A particle may correspond to one or more pixel point (there isa mapping relationship between the particle and the pixel point). Thestate change information (such as moving speed, etc.) of each particlemay be determined according to the pixel state information of thecorresponding pixel point, so as to obtain the candidate state changeinformation.

The hair directional angle indicates the direction of the hair filament,and the hair directional angles t of the particles are arrangedcorrespondingly to form the hair directional map. In other embodiments,the hair directional map may also store values of cos 2t and sin 2t toprevent the ambiguity of the hair direction on the same straight line.When the hair directional angle needs to be processed, the cost and sintmay be determined by the following formulas, respectively:

cost=sqrt((1+cos 2t)/2)*sign(sin 2t);

sint=sqrt(1-cost{circumflex over ( )}2),

where sign represents a sign function.

Further, t may be determined by: Sa. computing a grayscale image of thetarget image frame; Sb. computing a gradient image of the grayscaleimage; Sc. blurring the gradient image; and Sd.

taking a vertical vector of the blurred gradient image obtained in stepSc as the direction vector of each pixel, thereby obtaining t.

The mask is a string of binary codes that performs bitwise operations ona target field. The mask information of the hair region may indicatewhether the particle is in the hair region. The mask information of theparticles is arranged together to form the hair region mask map.

The directional angle of each particle may be obtained according to thehair directional angle in the hair directional map of a certain imageframe, while the position information, the size and the like of eachparticle may be obtained according to the hair region mask map of theimage frame. Further, based on the hair directional maps of adjacentimage frames, the rotation direction of each particle may be obtained;and based on the hair region mask maps of adjacent image frames, thelife cycle (for example, in a case where a certain particle is generatedin image frame A and disappears in image frame B, the number of framesbetween the image frame A and the image frame B may be used as the lifecycle of the particle), the speed information (for example, a certainparticle is at position c in image frame C and at position d in imageframe D, then the speed information of the particle may be determinedaccording to a distance between the position c and the position d and atime difference between the image frame C and the image frame D) of eachparticle may be obtained.

In addition, the hair directional map and the hair region mask map maybe obtained from the information of the target video through the neuralnetwork model. The neural network model may be a CNN (convolutionalneural network) model or the like.

In the above embodiment, the candidate motion state and the candidatestate change information of the target image frame are determinedaccording to the information of the target video, and are stored in thetexture image, which belong to the pre-processing of the target video,so that the subsequent hair rendering process can be carried outorderly.

In an exemplary embodiment, after the step of storing the candidatestate change information and the candidate motion state to the vertexposition of the at least one particle region, the hair rendering methodfurther includes: storing the texture image to a first frame buffer; andafter the step of updating the motion state in the texture imageaccording to the second target motion state, the method furtherincludes: storing the texture image in the first frame buffer to asecond frame buffer; and storing an updated texture image to the firstframe buffer.

In embodiments of the present disclosure, the candidate state changeinformation and the candidate motion state, after acquired, are storedin the corresponding vertex position in the texture image for later use.In a case where the hair needs to be rendered, the candidate statechange information and the candidate motion state corresponding to thetarget image frame are obtained from the texture image as the targetstate change information and the first target motion state,respectively.

In embodiments of the present disclosure, the texture image is stored bytwo frame buffers, i.e., the first frame buffer and the second framebuffer. The texture image stored in the first frame buffer may be usedas output (that is, displayed on the display screen), and the textureimage stored in the second frame buffer may be used as input. Forexample, when the image frame needs to be displayed, the texture imagein the first frame buffer is input into the second frame buffer, so thatoutput display of the image frame is performed according to the textureimage in the first frame buffer.

In addition, the input and output may also be switched between the firstframe buffer and the second frame buffer. For example, at the currentmoment, the texture image in the first frame buffer is output, and thesecond frame buffer is used as a backup of the first frame buffer tostore the texture image corresponding to the next image frame; at thenext moment, the texture image corresponding to the next image frame isoutput from the second frame buffer, and the first frame buffer is usedas a backup of the second frame buffer, and a newly determined textureimage corresponding to an image frame next to the next image frame isstored in the first frame buffer.

The above embodiments use double buffers to store the texture image,which can ensure the orderliness of the input and output of theinformation in the texture image, prevent data loss, and ensure theaccuracy of hair rendering.

In an exemplary embodiment, a flow chart of a hair rendering method isprovided. The hair rendering method is applied to the device as shown inFIG. 1 , and nay be implemented as follows, as illustrated in FIG. 5 .

In S501, a hair directional map and a hair region mask map are acquired.

In S502, particle information is read and written through double framebuffer. The particle information of a target image frame is acquiredfrom the hair directional map and the hair region mask map, the obtainedparticle information includes: a speed, a position, a rotation posture,a current life state and a size of a particle and a direction of a hairfilament, and the obtained particle information is stored by two piecesof texture. The texture that records the particle information is storedin the first frame buffer, and another frame buffer is used as a backupof the first frame buffer. For example, for the position, theacquisition process may be: initializing two pieces of texture, randomlygenerating particles on the full screen, and in response to a certainparticle being in the hair region, writing a screen coordinate of theparticle into the frame buffer; for the direction of the hair filament,cost and sint are determined according to cos 2t and sin 2t stored inthe hair directional map, so as to obtain the direction of the hairfilament, D(cost, sint).

In S503, a speed of a target particle is updated. A speed v2(u,v) of thetarget particle in the next image frame is determined according to thedirection of the hair filament, D(cost, sint) and a velocity scalar V:v2(u,v)=D(cost, sint)*V, and the speed of the target image frame isupdated according to the speed v2(u,v).

In S504, a position of the target particle is updated. A position of thetarget particle in the next image frame is determined according to aparticle speed vl(u,v) in the target image frame: P(u,v)=P_prev(u,v)+vl(u,t)*delta_t, where P_prev(u, v) represents the position of thetarget particle in the target image frame, delta_t represents a timeincrement, and P_prev(u, v) is updated according to P(u,v). In a casewhere the updated particle position is out of the range of the hairregion, a random particle position is regenerated on the screen, and theposition is redetermined and updated.

In S505, states of remaining particles are retained. The speed andposition of the remaining particles in the next image frame adopt thespeed and position in the target image frame.

The foregoing embodiments achieves the following beneficial effects:

1. The hair particles are integrated into particle bunches, which avoidsthe disorder of the hair and realizes the smooth rendering effect of“optical flow”.

2. Most video effects implemented with traditional techniques arerelatively simple, while the GPU particle technology is complex toimplement, so it is difficult to promote it into a fixed mode.Therefore, the general demand still uses traditional CPU computing torealize particle system. However, the foregoing embodiments use the GPUto implement the computation of the particle information, which makesthe GPU particle system implemented, and greatly improves the computingefficiency of the particle system, so that real-time rendering of thehair on the mobile terminal is realized.

It should be understood that although the steps in the flow charts ofFIG. 2 and FIG. 5 are sequentially displayed according to the arrows,these steps are not necessarily executed in the order indicated by thearrows. Unless explicitly stated herein, the order of execution of thesesteps is not strictly limited, and the steps may be executed in otherorders. Moreover, at least a part of the steps in FIG. 2 and FIG. 5 mayinclude multiple steps or multiple stages, and these steps or stages arenot necessarily executed at the same time, but may be executed atdifferent moments. These steps or stages are also not necessarily to beperformed sequentially, but may be performed in turn or alternately withother steps or at least a portion of the steps or stages in the othersteps.

FIG. 6 is a block diagram of a hair rendering apparatus 600 according toan exemplary embodiment. Referring to FIG. 6 , the apparatus includes animage frame determining unit 601, a texture image acquiring unit 602, astate information acquiring unit 603, a motion state determining unit604 and a motion state updating unit 605.

The image frame determining unit 601 is configured to acquire a targetvideo containing hair information, and select a target image frame fromimage frames of the target video.

The texture image acquiring unit 602 is configured to acquire a textureimage of the target image frame. The texture image is an image in atexture format which records motion states and state change informationof one or more pixel points in the target image frame, and a hair regionin the texture image is divided into at least one particle region by agrid line.

The state information acquiring unit 603 is configured to acquire afirst target motion state and target state change information of a firsttarget particle region from the texture image.

The motion state determining unit 604 is configured to determine asecond target motion state of the first target particle region in a nextimage frame according to the first target motion state and the targetstate change information. The next image frame is an image frame in thetarget video next to the target image frame.

The motion state updating unit 605 is configured to render the hairregion by updating a motion state in the texture image according to thesecond target motion state.

With the hair rendering apparatus provided by above embodiments of thepresent disclosure, the texture image of the target image frame isacquired according to the target video containing the hair information,and the texture image can be processed by the GPU; the hair region inthe texture image is divided into at least one particle region, and theparticle region is processed by the GPU, which greatly simplifies thegraphics processing of the GPU and improves the graphics processingefficiency of the GPU, so that the computation on the mobile terminal isrealized; in addition, the first target motion state and the targetstate change information of the target particle region are acquired fromthe texture image, based on which the second target motion state of thefirst target particle region in the next image frame is determined, andthe motion state in the texture image is updated according to the secondtarget motion state to realize the rendering of the hair region. Theabove technical solution according to the present disclosure is able torender the hair region in real time on the mobile terminal, and at thesame time is able to modify the motion state of a particular particleregion, so that a special rendering effect that particles flow along thedirection of the hair filament may be realized.

In an exemplary embodiment, the motion state updating unit is furtherconfigured to update a motion state of the first target particle regionaccording to the second target motion state, and retain a motion stateof a remaining particle region. The remaining particle region is aparticle region of the at least one particle region other than the firsttarget particle region.

In an exemplary embodiment, the first target motion state includes afirst screen coordinate, and the target state change informationincludes a first speed. The motion state determining unit includes: atime difference determining subunit, configured to determine a timedifference between the target image frame and the next image frame; anda first motion state determining subunit, configured to determine asecond screen coordinate of the first target particle region in the nextimage frame according to the first screen coordinate, the first speedand the time difference; and determine the second target motion statebased on the second screen coordinate.

In an exemplary embodiment, the motion state updating unit includes: aparticle region determining subunit, configured to: in response to thesecond screen coordinate being outside the hair region, redetermine thehair region of the texture image and determine a second target particleregion from particle regions corresponding to the redetermined hairregion; a state information acquiring subunit, configured to acquire areference target motion state and reference target state changeinformation of the second target particle region from the texture image;a second motion state determining subunit, configured to obtaining athird target motion state by determining a motion state of the secondtarget particle region in the next image frame according to thereference target motion state and the reference target state changeinformation; and a motion state updating subunit, configured to updatethe motion state in the texture image according to the third targetmotion state.

In an exemplary embodiment, the first target motion state includes asecond speed, and the target state change information includes a hairdirectional angle. The motion state determining unit includes: a rateacquiring subunit, configured to acquire a preset rate; and a thirdmotion state determining subunit, configured to obtain the second targetmotion state by determining a third speed of the first target particleregion in the next image according to the second speed, the hairdirectional angle and the preset rate.

In an exemplary embodiment, the hair rendering apparatus furtherincludes: a state change information determining unit, configured todetermine candidate state change information of each pixel point in thetarget image frame according to pixel state information in the targetvideo which varies over time; an image acquiring unit, configured toacquire a hair directional map and a hair region mask map correspondingto the target image frame, wherein the hair directional map includes ahair directional angle of the pixel point, and the hair region mask mapincludes mask information of the hair region in the target image frame;a candidate motion state determining unit, configured to determine acandidate motion state of the pixel point according to the hairdirectional angle in the hair directional map and the mask informationin the hair region mask map; and a candidate motion state storing unit,configured to store the candidate state change information and thecandidate motion state to a vertex position of the at least one particleregion, wherein the vertex position of the at least one particle regioncorresponds to the pixel point.

In an exemplary embodiment, the hair rendering apparatus furtherincludes: a first image storing unit, configured to store the textureimage to a first frame buffer; an image dumping unit, configured tostore the texture image in the first frame buffer to a second framebuffer; and a second image storing unit, configured to store the updatedtexture image to the first frame buffer.

In an exemplary embodiment, the hair rendering apparatus furtherincludes: a region determining unit, configured to determine the hairregion in the texture image; a region dividing unit, configured to meshthe hair region according to the preset number of particle bunches tocorrespondingly obtain at least one particle bunch; and a particle bunchdividing unit, configured to mesh each of the at least one particlebunch according to the preset number of particles to correspondinglyobtain at least one particle region.

In an exemplary embodiment, the hair rendering apparatus furtherincludes: a particle region determining unit, configured to determine aparticle region at a preset position of the at least one particle bunchas the first target particle region.

Regarding the apparatus in the above-mentioned embodiments, the specificmanner in which each module performs the operation has been described indetail in the embodiments of the related method, which will not beelaborated here.

In an exemplary embodiment, there is also provided an electronic device,the schematic diagram of which may be as shown in FIG. 1 . Theelectronic device includes: a processor; and a memory, configured tostore an instruction executable by the processor. The processor isconfigured to execute the instruction to implement the hair renderingmethod as described in embodiments hereinbefore.

In an exemplary embodiment, there is also provided a non-transitorycomputer readable storage medium including instructions, such as thememory 102 including instructions, and the instructions are executableby the processor 101 of the electronic device 100 to perform the hairrendering method as described in embodiments hereinbefore. For example,the non-transitory computer-readable storage medium may be a read-onlymemory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, afloppy disc, an optical data storage device, and the like.

In an exemplary embodiment, there is provided a computer programproduct. The program product includes a computer program, and thecomputer program is stored in a readable storage medium. The computerprogram, when read from the readable storage medium and executed by atleast one processor of a device, causes the device to perform the hairrendering method as described in embodiments hereinbefore.

Other embodiments of the present disclosure will be apparent to thoseskilled in the art from consideration of the specification and practiceof the present disclosure disclosed herein. The present disclosure isintended to cover any variations, uses, or adaptive modifications of thepresent disclosure following the general principles of the presentdisclosure and including common general knowledge or conventionaltechniques in the art not disclosed by this disclosure. It is intendedthat the specification and embodiments are merely considered asexemplary only, with a true scope and spirit of the present disclosurebeing indicated by the following claims.

It will be appreciated that the present disclosure is not limited to theexact construction that has been described above and illustrated in theaccompanying drawings, and that various modifications and changes can bemade without departing from the scope thereof. It is intended that thescope of the present disclosure is only limited by the appended claims.

What is claimed is:
 1. A hair rendering method, comprising: acquiring atarget video containing hair information, and selecting a target imageframe from image frames of the target video; acquiring a texture imageof the target image frame, wherein the texture image is an image in atexture format which records motion states and state change informationof one or more pixel points in the target image frame, and a hair regionin the texture image is divided into at least one particle region by agrid line; acquiring a first target motion state and target state changeinformation of a first target particle region from the texture image,wherein the first target particle region is any region of the at leastone particle region; determining a second target motion state of thefirst target particle region in a next image frame according to thefirst target motion state and the target state change information,wherein the next image frame is an image frame in the target video nextto the target image frame; and rendering the hair region by updating amotion state in the texture image according to the second target motionstate.
 2. The hair rendering method according to claim 1, wherein saidupdating the motion state in the texture image according to the secondtarget motion state comprises: updating a motion state of the firsttarget particle region according to the second target motion state, andretaining a motion state of a remaining particle region, wherein theremaining particle region is a particle region of the at least oneparticle region other than the first target particle region.
 3. The hairrendering method according to claim 1, wherein the first target motionstate comprises a first screen coordinate, and the target state changeinformation comprises a first speed; said determining the second targetmotion state of the first target particle region in the next image frameaccording to the first target motion state and the target state changeinformation comprises: determining a time difference between the targetimage frame and the next image frame; determining a second screencoordinate of the first target particle region in the next image frameaccording to the first screen coordinate, the first speed and the timedifference; and determining the second target motion state based on thesecond screen coordinate.
 4. The hair rendering method according toclaim 3, wherein said updating the motion state in the texture imageaccording to the second target motion state comprises: in response tothe second screen coordinate being outside the hair region,redetermining the hair region of the texture image and determining asecond target particle region from particle regions corresponding to theredetermined hair region; acquiring a reference target motion state anda reference target state change information of the second targetparticle region from the texture image; obtaining a third target motionstate by determining a motion state of the second target particle regionin the next image frame according to the reference target motion stateand the reference target state change information; and updating themotion state in the texture image according to the third target motionstate.
 5. The hair rendering method according to claim 1, wherein thefirst target motion state comprises a second speed, and the target statechange information comprises a hair directional angle; said determiningthe second target motion state of the first target particle region inthe next image frame according to the first target motion state and thetarget state change information comprises: acquiring a preset rate; andobtaining the second target motion state by determining a third speed ofthe first target particle region in the next image according to thesecond speed, the hair directional angle and the preset rate.
 6. Thehair rendering method according to claim 1, further comprising:determining candidate state change information of each pixel point inthe target image frame according to pixel state information in thetarget video which varies over time; acquiring a hair directional mapand a hair region mask map corresponding to the target image frame,wherein the hair directional map comprises a hair directional angle ofthe pixel point, and the hair region mask map comprises mask informationof the hair region in the target image frame; determining a candidatemotion state of the pixel point according to the hair directional anglein the hair directional map and the mask information in the hair regionmask map; and storing the candidate state change information and thecandidate motion state to a vertex position of the at least one particleregion, wherein the vertex position of the at least one particle regioncorresponds to the pixel point.
 7. The hair rendering method accordingto claim 6, after storing the candidate state change information and thecandidate motion state to the vertex position of the at least oneparticle region, further comprising: storing the texture image to afirst frame buffer; wherein after updating the motion state in thetexture image according to the second target motion state, the methodfurther comprises: storing the texture image in the first frame bufferto a second frame buffer; and storing an updated texture image to thefirst frame buffer.
 8. The hair rendering method according to claim 1,after acquiring the texture image of the target image frame, furthercomprising: determining the hair region in the texture image; meshingthe hair region according to the preset number of particle bunches tocorrespondingly obtain at least one particle bunch; and meshing each ofthe at least one particle bunch according to the preset number ofparticles to correspondingly obtain at least one particle region.
 9. Thehair rendering method according to claim 8, before acquiring the firsttarget motion state and the target state change information of the firsttarget particle region from the texture image, further comprising:determining a particle region at a preset position of the at least oneparticle bunch as the first target particle region.
 10. An electronicdevice, comprising: a processor; a memory, configured to store aninstruction executable by the processor, wherein the processor isconfigured to execute the instruction to: acquire a target videocontaining hair information, and select a target image frame from imageframes of the target video; acquire a texture image of the target imageframe, wherein the texture image is an image in a texture format whichrecords motion states and state change information of one or more pixelpoints in the target image frame, and a hair region in the texture imageis divided into at least one particle region by a grid line; acquire afirst target motion state and target state change information of a firsttarget particle region from the texture image, wherein the first targetparticle region is any region of the at least one particle region;determine a second target motion state of the first target particleregion in a next image frame according to the first target motion stateand the target state change information, wherein the next image frame isan image frame in the target video next to the target image frame; andrender the hair region by updating a motion state in the texture imageaccording to the second target motion state.
 11. The electronic deviceaccording to claim 10, wherein the processor is configured to executethe instruction to: update a motion state of the first target particleregion according to the second target motion state, and retain a motionstate of a remaining particle region, wherein the remaining particleregion is a particle region of the at least one particle region otherthan the first target particle region.
 12. The electronic deviceaccording to claim 10, wherein the first target motion state comprises afirst screen coordinate, and the target state change informationcomprises a first speed; wherein the processor is configured to executethe instruction to: determine a time difference between the target imageframe and the next image frame; determine a second screen coordinate ofthe first target particle region in the next image frame according tothe first screen coordinate, the first speed and the time difference;and determine the second target motion state based on the second screencoordinate.
 13. The electronic device according to claim 12, wherein theprocessor is configured to execute the instruction to: in response tothe second screen coordinate being outside the hair region, redeterminethe hair region of the texture image and determining a second targetparticle region from particle regions corresponding to the redeterminedhair region; acquire a reference target motion state and a referencetarget state change information of the second target particle regionfrom the texture image; obtain a third target motion state bydetermining a motion state of the second target particle region in thenext image frame according to the reference target motion state and thereference target state change information; and update the motion statein the texture image according to the third target motion state.
 14. Theelectronic device according to claim 10, wherein the first target motionstate comprises a second speed, and the target state change informationcomprises a hair directional angle; wherein the processor is configuredto execute the instruction to: acquire a preset rate; and obtain thesecond target motion state by determining a third speed of the firsttarget particle region in the next image according to the second speed,the hair directional angle and the preset rate.
 15. The electronicdevice according to claim 10, wherein the processor is furtherconfigured to execute the instruction to: determine candidate statechange information of each pixel point in the target image frameaccording to pixel state information in the target video which variesover time; acquire a hair directional map and a hair region mask mapcorresponding to the target image frame, wherein the hair directionalmap comprises a hair directional angle of the pixel point, and the hairregion mask map comprises mask information of the hair region in thetarget image frame; determine a candidate motion state of the pixelpoint according to the hair directional angle in the hair directionalmap and the mask information in the hair region mask map; and store thecandidate state change information and the candidate motion state to avertex position of the at least one particle region, wherein the vertexposition of the at least one particle region corresponds to the pixelpoint.
 16. The electronic device according to claim 15, wherein theprocessor is configured to execute the instruction to store the textureimage to a first frame buffer; wherein the processor is furtherconfigured to execute the instruction to: store the texture image in thefirst frame buffer to a second frame buffer; and store an updatedtexture image to the first frame buffer.
 17. The electronic deviceaccording to claim 10, wherein the processor is configured to executethe instruction to: determine the hair region in the texture image; meshthe hair region according to the preset number of particle bunches tocorrespondingly obtain at least one particle bunch; and mesh each of theat least one particle bunch according to the preset number of particlesto correspondingly obtain at least one particle region.
 18. Theelectronic device according to claim 17, wherein the processor isconfigured to execute the instruction to: determine a particle region ata preset position of the at least one particle bunch as the first targetparticle region.
 19. A storage medium having stored therein instructionsthat, when executed by a processor of an electronic device, cause theelectronic device to: acquire a target video containing hairinformation, and select a target image frame from image frames of thetarget video; acquire a texture image of the target image frame, whereinthe texture image is an image in a texture format which records motionstates and state change information of one or more pixel points in thetarget image frame, and a hair region in the texture image is dividedinto at least one particle region by a grid line; acquire a first targetmotion state and target state change information of a first targetparticle region from the texture image, wherein the first targetparticle region is any region of the at least one particle region;determine a second target motion state of the first target particleregion in a next image frame according to the first target motion stateand the target state change information, wherein the next image frame isan image frame in the target video next to the target image frame; andrender the hair region by updating a motion state in the texture imageaccording to the second target motion state to.
 20. The storage mediumaccording to claim 19, wherein the instructions, when executed by theprocessor of the electronic device, cause the electronic device to:update a motion state of the first target particle region according tothe second target motion state, and retain a motion state of a remainingparticle region, wherein the remaining particle region is a particleregion of the at least one particle region other than the first targetparticle region.